package com.gxuwz.PangGuangyao.business.action.web;

import org.apache.poi.hssf.record.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;

import com.gxuwz.PangGuangyao.business.entity.Culum;
import com.gxuwz.PangGuangyao.business.entity.ExpeCata;
import com.gxuwz.PangGuangyao.business.entity.FunalClass;
import com.gxuwz.PangGuangyao.business.entity.SysUser;
import com.gxuwz.PangGuangyao.business.service.ICulumService;
import com.gxuwz.PangGuangyao.business.service.IExpeCataService;
import com.gxuwz.PangGuangyao.business.service.IFunalClassService;
import com.gxuwz.core.pagination.Result;
import com.gxuwz.core.web.action.BaseAction;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

public class ExpeCataAction extends BaseAction implements Preparable,ModelDriven{

	@Autowired
	private IExpeCataService expeCataService;
	@Autowired
	IFunalClassService funalClassService;
	@Autowired
	ICulumService culumService;
	
	private ExpeCata expeCata;
	private FunalClass funalClass;
	private Culum culum;
	private String  CId;
	private String fcId;
	private Result<ExpeCata> pageResult;//分页
	private  final  String LIST_JSP="/WEB-INF/page/web/ExpeCata_list.jsp";
	private  final  String ADD_JSP="/WEB-INF/page/web/ExpeCata_add.jsp";

	@Override
	public Object getModel() {
		// TODO Auto-generated method stub
		return expeCata;
	}

	@Override
	public void prepare() throws Exception {
		if(null==expeCata)
			expeCata =new ExpeCata();
		
	}
	/**
	 * 
	 * @return
	 * @author lwt
	 * @date 2020.02.20
	 * @description:获取目录列表
	 */
	  public String getExpeCataList()
	  {
		  pageResult =expeCataService.find(expeCata, getPage(), getRow());
		  forwardView=LIST_JSP;
		  return SUCCESS;
		  
		
		  
	  }/**
	   * @return
	   * @author lw
	   * @date 2020.02.20
	   * @description:打开添加目录的列表
	   */
	  public String openAdd(){
		  forwardView=ADD_JSP;
		  return SUCCESS;
	  }
	  /**
	   * @return
	   * @author lw
	   * @date 2020.02.20
	   * @description:添加目录列表
	   */
	  
	  public String add(){
		  
	
		culum =new Culum();
		funalClass =new FunalClass();
		System.out.println(CId);
		culum.setCId(CId);
		funalClass.setFcId(fcId);
		System.out.println(fcId);
		expeCata.setCulum(culum);
		expeCata.setFunalClass(funalClass);
		culum=  culumService.findByCId(culum);
		System.out.println(null==culum);
		funalClass=    funalClassService.findByfcId(funalClass);
		expeCata.setCulum(culum);
		expeCata.setFunalClass(funalClass);
		  expeCataService.add(expeCata);
		  return getExpeCataList();
		  
		  /*forwardView=ADD_JSP;
		  return SUCCESS;*/
		  
	  }
	 public String delete(){
		 System.out.println("ecId==="+expeCata.getEcId());
		 expeCata= expeCataService.findByecId(expeCata.getEcId());
		 expeCataService.delete(expeCata);
		return getExpeCataList();
		 
	 }

	public Result<ExpeCata> getPageResult() {
		return pageResult;
	}

	public void setPageResult(Result<ExpeCata> pageResult) {
		this.pageResult = pageResult;
	}

	public String getCId() {
		return CId;
	}

	public void setCId(String cId) {
		CId = cId;
	}

	public String getFcId() {
		return fcId;
	}

	public void setFcId(String fcId) {
		this.fcId = fcId;
	}

	
	  
	  
	

}
